import request from "@/api/index";
interface dataSourceType {
  [propName: string]: any;
}
export const checkGroupName = async (_rule: dataSourceType = {}, value: any) => {
  if (!value) {
    return Promise.reject(`${_rule.msg1}`);
  } else {
    var params = Object.assign(_rule.params, {
      groupName: value,
    })
    if (_rule.api) {

      let res = await request[`${_rule.api}`](params);
      if (!res) {
        return Promise.reject(`${_rule.msg2}`);
      } else {
        return Promise.resolve();
      }
    }

  }
};
export const checkSelectAuth = async (_rule: dataSourceType = {}, value: any) => {
  const keys = _rule.params.key || []
  console.log(keys, 11111);
  if(keys === true) {
    return Promise.resolve();
  }
  if (!keys.length) {
    return Promise.reject(`${_rule.msg1}`);
  } else {
    return Promise.resolve();
  }
};